<%@ page import="com.edu.dreams.entity.User"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>童话世界</title>
<meta name="description" content="一个充满童话世界的地方，带你回味童年." />
<meta name="keywords" content="童话、英雄和魔法" />
<link rel="shortcut icon" href="images/favicon.ico" />
<!-- 引入bootstrap 样式文件 -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- 引入我们自己的样式文件 -->
<link rel="stylesheet" href="css/news.css">
<!-- 先引入jquery js文件 -->
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>

<%
	User user = (User) request.getSession().getAttribute("user");
%>
<body>
	<div class="container">

		<!--  导航栏 -->
		<div class="row">
			<nav class="navbar navbar-default">
				<div class="container">
					<div class="navbar-header">
						<button type="button" class="navbar-toggle collapsed"
							data-toggle="collapse"
							data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
							<span class="sr-only">Toggle navigation</span> <span
								class="icon-bar"></span> <span class="icon-bar"></span> <span
								class="icon-bar"></span>
						</button>
						<a class="navbar-brand"
							href="${pageContext.request.contextPath}/home"><img
							style="margin-left: 15px;" src="images/logo.jpg" alt="童话世界"></a>
					</div>

					<div class="collapse navbar-collapse"
						id="bs-example-navbar-collapse-1">
						<ul class="nav navbar-nav">
							<li><a href="${pageContext.request.contextPath}/home">首页
									<span class="sr-only">(current)</span>
							</a></li>
							<li><a href="${pageContext.request.contextPath}/animations">动画</a></li>
							<li class="active"><a
								href="${pageContext.request.contextPath}/news">资讯</a></li>
							<li><a href="${pageContext.request.contextPath}/rank">排行榜</a></li>
							<li><a href="${pageContext.request.contextPath}/personal">个人中心</a></li>
						</ul>
						<form action="${pageContext.request.contextPath}/searchAnim"
							method="post" class="navbar-form navbar-left">
							<div class="form-group">
								<input type="text" name="animname" class="form-control"
									placeholder="搜索动画">
							</div>
							<button type="submit" class="btn btn-default">搜索</button>
						</form>
						<ul class="nav navbar-nav navbar-right">
							<li><a href="${pageContext.request.contextPath}/personal"><%=user.getUser_name()%> </a></li>
							<li><a href="${pageContext.request.contextPath}/logout">退出登录</a></li>
						</ul>
					</div>
					<!-- /.navbar-collapse -->
				</div>
				<!-- /.container-fluid -->
			</nav>
		</div>

		<!-- 主体 -->
		<div class="row">

			<header class="col-md-2">
					
			<form action="searchNews" method="post">
				<div class="form-group">
				<input type="text" name="animname" placeholder="搜索新闻" class="search form-control">
				</div>
				 <button type="submit" class="btn btn-default">搜索</button>
			</form>
						
				<div class="nav" style=" margin-top:20px">
					<ul>
						<li><a href="${pageContext.request.contextPath}/home"
							class="glyphicon glyphicon-home">首页</a></li>
						<li><a href="${pageContext.request.contextPath}/animations"
							class="glyphicon glyphicon-tree-conifer">动画</a></li>
						<li class="active"><a
							href="${pageContext.request.contextPath}/news"
							class="glyphicon glyphicon-cloud">资讯</a></li>
						<li><a href="${pageContext.request.contextPath}/rank"
							class="glyphicon glyphicon-stats">排行榜</a></li>
						<li><a href="${pageContext.request.contextPath}/personal"
							class="glyphicon glyphicon-user">个人中心</a></li>
					</ul>
				</div>
			</header>

			<article class="col-md-7">

				<!-- 资讯 -->
				<div class="news clearfix">
					<ul>
						<li>
							<div id="carousel-example-generic" class="carousel slide"
								data-ride="carousel">
								<div class="carousel-inner" role="listbox">
									<c:forEach var="item" begin="0" end="2" items="${newsdata}"
										varStatus="status">
										<c:choose>
											<c:when test="${status.first}">
												<div class="item active">
													<img
														src="${pageContext.request.contextPath}/upload/${item.news_picurl}"
														alt="${item.news_name}">
													<div class="carousel-caption">${item.news_name}</div>
												</div>
											</c:when>
											<c:otherwise>
												<div class="item">
													<img
														src="${pageContext.request.contextPath}/upload/${item.news_picurl}"
														alt="${item.news_name}">
													<div class="carousel-caption">${item.news_name}</div>
												</div>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</div>

								<!-- Controls -->
								<a class="left carousel-control" role="button"
									href="#carousel-example-generic" data-slide="prev"> <span
									class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
									<span class="sr-only">Previous</span>
								</a> <a class="right carousel-control" role="button"
									href="#carousel-example-generic" data-slide="next"> <span
									class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
									<span class="sr-only">Next</span>
								</a>
							</div> <script>
								$('.carousel').carousel({
									interval : 2000
								})
							</script>
						</li>
						<c:forEach var="item" begin="0" end="3" items="${newsdata}"
							varStatus="status">
							<li><a
								href="${pageContext.request.contextPath}/newsshow?id=${item.news_id}">
									<img
									src="${pageContext.request.contextPath}/upload/${item.news_picurl}"
									alt="${item.news_name}">
									<p>${item.news_content.length()>25?item.news_content.substring(0,25):item.news_content}...</p>
							</a></li>
						</c:forEach>
					</ul>
				</div>
				<!-- 发表 -->

				<div class="publish">
					<c:forEach var="item" begin="0" end="5" items="${newsdata}">
						<div class="row">
							<div class="col-sm-3 pic hidden-xs">
								<a
									href="${pageContext.request.contextPath}/newsshow?id=${item.news_id}"><img
									src="${pageContext.request.contextPath}/upload/${item.news_picurl}"
									alt="${item.news_name}"></a>
							</div>
							<div class="col-sm-9">
								<a
									href="${pageContext.request.contextPath}/newsshow?id=${item.news_id}">
									<h3>${item.news_name}</h3>
									<p class="text-muted foot">${item.news_src}&nbsp;&nbsp;&nbsp;&nbsp;${item.news_time.substring(0,10)}</p>
								</a>
							</div>
						</div>
					</c:forEach>
				</div>
			</article>

			<aside class="col-md-3">
				<a href="#" class="banner"> <img src="images/foot2.jpg" alt=""
					class="foot1">
				</a>
				
				 <a href="news.html" class="hot"> <span class="btn btn-primary">动态</span>
					<h4 class="text-primary">欢迎欣赏动漫资讯</h4>
					<p>这里收录各个动漫资讯，带你深入了解动漫......</p>
				</a>
				<div style="margin-top: 30px;">
					<div class="list-group">
						<a href="javascript:;" class="list-group-item"
							style="color: blue; font-size: 26px;">漫圈动态</a>
						<c:forEach var="item" begin="0" end="5" items="${newsdata}">
							<a
								href="${pageContext.request.contextPath}/newsshow?id=${item.news_id}"
								class="list-group-item">${item.news_name}</a>
						</c:forEach>
					</div>
				</div>
			</aside>

		</div>

		<!--  页面尾部 -->
		<div class="footer container">
			<hr>
			<p class="text-center">2020-forever</p>
		</div>
	</div>
</body>
</html>